package app {
	
	import app.model.vo.BallVO;
	import app.model.vo.BallVO;
	import com.hutra.utils.ArrayUtilities;
	import flash.display.MovieClip;
	import flash.events.Event;
	import com.temple.core.CoreMovieClip;
	
	/**
	 * ...
	 * @author hungconcon
	 */
	public class BallFactory extends CoreMovieClip {
		
		public var rotationSpeed:Number;
		private var list:Array;
		
		public function BallFactory() { }
		
		public function createTest(xx:int,yy:int, up:Boolean = false):void {
				var ball:Ball = createBall(0);
					ball.x = xx;
					ball.y = yy;
					ball.vo = new BallVO();
					ball.addEnter();
			App.balls.push(ball);
			
			if(up) ball.goingUp();
		}
		
		public function onShoot():void {
			createTest(App.p_x,App.p_y, true);
		}
		public function createBall(index:int):Ball {
			var ball:Ball = new Ball();
				ball.rotationSpeed = rotationSpeed;
				addChild(ball);
			return ball;
		}
		
		public function deleteBallOnList(ball:Ball):void {
			if (ball == null) return;
			for (var i:int = 0; i < App.balls.length; i++)
				if(App.balls[i]==ball){
					remove(ball);
					ArrayUtilities.removeAt(App.balls, i);
					break;
				}
				
			trace(App.balls);
				
			
		}
		public function remove(ball:*):void {
			try{
				removeChild(ball);
			}catch(ex:Error){
			}
		}
	}

}